package com.seer.srd.qingdao

import com.seer.srd.Application
import com.seer.srd.BusinessError
import com.seer.srd.qingdao.CustomHandler.registerCustomHttpHandlers
import com.seer.srd.robottask.component.registerRobotTaskComponents
import com.seer.srd.roboview.RoboViewService
import com.seer.srd.setVersion
import com.seer.srd.storesite.StoreSiteService
import com.seer.srd.util.mapper
import org.litote.kmongo.json

fun main() {
    setVersion("青岛一汽", "1.0.9")
    Application.initialize()
    QingDaoFAWApp.init()
    Application.start()
    var s = "WT-TW101-1"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW101-2"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW102-1"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW102-2"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW102H-1"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW102H-2"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW103-1"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
    s = "WT-TW103-2"
    for(x in 1..8){
        val siteById = StoreSiteService.getStoreSiteById(s+"-${x}")
        siteById?.let { StoreSiteService.clearInputFailedReason(it,"") }
    }
}

object QingDaoFAWApp {
    fun init() {
        registerRobotTaskComponents(ExtraComponent.extraComponents)
        registerCustomHttpHandlers()

        CustomHandler.checkBoardCheckSiteId(true)
        CustomDataService.init()

        PlcListener.init()
        NewTaskListener.init()
    }
}